<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="js/jquery-3.2.1.min.js" ></script>
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css" />
<link rel="stylesheet" href="bootstrap/css/bootstrap-responsive.min.css" />
<script type="text/javascript" src="bootstrap/js/bootstrap.min.js" ></script>
<link type="text/css" rel="stylesheet" href="css/cityLayout.css"/>
<script type="text/javascript" src="js/cityselect.js"></script>
<script type="text/javascript">
	$(function(){
		init_city_select($("#citySelect"));
		$("#btn-primary").click(function(){
			var o_code=$("#o_code").val();
			var u_name=$("#u_name").val();
			var o_price=$("#o_price").val();
			var pay=$("#pay").val();
			$.get("lreceipt?action=add",{code:o_code,name:u_name,price:o_price,pay:pay},function(){
			});
		});
		$("#bprimary").click(function(){
			var o_code=$("#o_code").val();
			var freight=$("#freight").val();
			var r_name=$("#r_name").val();
			var u_id=$("#u_id").val();
			var phone=$("#phone").val();
			var tel=$("#tel").val();
			var zip_code=$("#zip_code").val();
			var e_id=$("#e_name").val();
			var courier_num=$("#courier_num").val();
			var citySelect=$("#citySelect").val();
			var address=$("#address").val();
			$.get("linvoice?action=add",{code:o_code,freight:freight,uid:u_id,rname:r_name,phone:phone,tel:tel,zipcode:zip_code,eid:e_id,couriernum:courier_num,citySelect:citySelect,address:address},function(){
			});
		});
		$("#primary").click(function(){
			var o_code=$("#o_code").val();
			var u_name=$("#u_name").val();
			var gather_m=$("#gather_m").val();
			var a=$("input[name='checkbox']:checked");
			if(a.length==0){
            	alert("至少选中一个");
            	return;
            } 
			//获取所有已选的id存到集合
			var list=[];
			$("input[name='checkbox']:checked").each(function(i, o){
				list.push($(o).attr("id"));
            });
			for(var i=0;i<a.length;i++){
				$.get("lreturn?action=add",{code:o_code,name:u_name,gather:gather_m,list:list[i]},function(){
				});
			}
			var pay=$("#pay").val();
			if(pay==0){
				$(".returnpay").append("支付宝");
			}else{
				$(".returnpay").append("微信");
			}
		});
		$("#selectrr").click(function(){
			var o_code=$("#o_code").val();
			$.getJSON("lreceipt?action=querySelectrr",{code:o_code},function(e){
				var tr1=$("<tr><td style='text-align: right; width: 100px;'>付款时间：</td><td>"+e.strdonedate+"</td></tr>");
				var tr2=$("<tr class='success'><td style='text-align: right; width: 100px;'>金额：</td><td>"+e.gather_m+"</td></tr>");
				var tr3=$("<tr class='error'><td style='text-align: right; width: 100px;'>支付方式：</td><td>"+e.pay+"</td></tr>");
				var tr4=$("<tr class='warning'><td style='text-align: right; width: 100px;'>状态：</td><td>支付完成</td></tr>");
				$("#receipt").children().remove();
				$("#receipt").append(tr1);
				$("#receipt").append(tr2);
				$("#receipt").append(tr3);
				$("#receipt").append(tr4);
			});
			$.getJSON("lreturn?action=querySelectrr",{code:o_code},function(e){
				for(var i=0;i<e.length;i++){
					var tr1=$("<tr><td style='text-align: right; width: 100px;'>退款商品：</td><td>"+e[i].g_name+"</td></tr>");
					var tr2=$("<tr class='success'><td style='text-align: right; width: 100px;'>退款金额：</td><td>"+e[i].gather_m+"</td></tr>");
					var tr3=$("<tr class='error'><td style='text-align: right; width: 100px;'>申请时间：</td><td>"+e[i].strdonedate+"</td></tr>");
					var tr4=$("<tr class='info'><td style='text-align: right; width: 100px;'>状态：</td><td>退款完成</td></tr>");
					var tr5=$("<tr class='warning'><td style='text-align: right; width: 100px;'>退款理由：</td><td>"+e[i].reason+"</td></tr>");
					var tr6=$("<tr class='error'><td style='text-align: right; width: 100px;'>退款方式：</td><td class='returnpay'></td>");
					$("#return").append(tr1);
					$("#return").append(tr2);
					$("#return").append(tr3);
					$("#return").append(tr4);
					$("#return").append(tr5);
					$("#return").append(tr6);
				}
			});
		});
	});
</script>
</head>
<style>
	*{
		margin:0;
		padding:0;
	}
</style>
<body>
	<div class="top" style=" padding: 20px 30px 10px;font-size:16px;">
		<a href="#">订单</a>/ 
		<a href="#">订单管理</a>/ 
		<span>订单查看</span>
	</div>
	<div class="bottom">
		<div class="span12" style="background-color: #CCCCCC; padding: 10px 5px; border-radius: 5px;width:96%;">
			<a id="modal-959341" href="#modal-container-959341" role="button" class="btn btn-primary" data-toggle="modal">支付</a>	
			<a id="modal-959341" href="#modal-container-959342" role="button" class="btn btn-danger" data-toggle="modal">发货</a>
			<a id="modal-959341" href="#modal-container-959343" role="button" class="btn btn-warning" data-toggle="modal">退款</a>
			<a id="modal-959341" href="#modal-container-959341" role="button" class="btn btn-success" data-toggle="modal">完成</a>
			<a id="modal-959341" href="#modal-container-959341" role="button" class="btn btn-inverse" data-toggle="modal">作废</a>	
			<div id="modal-container-959341" class="modal hide fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
				<div class="modal-header" style="border-bottom:0px;">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
					<span id="myModalLabel">订单号：${order.o_code}【付款】</span>
				</div>
				<div class="modal-body" style="padding:0px;">
					<div class="row-fluid">
						<table class="table table-bordered" style="margin:0px;">
							<tr>
								<td style="text-align: right; width: 100px;">订单号：</td>
								<td>${order.o_code}<input type="hidden" id="o_code" value="${order.o_code}"></td>
							</tr>
							<tr>
								<td style="text-align: right; width: 100px;">下单时间：</td>
								<td>${order.buy_date}<input type="hidden" id="u_name" value="${user.u_name}"></td>
							</tr>
							<tr>
								<td style="text-align: right; width: 100px;">订单金额：</td>
								<td><input type="text" id="o_price" value="${aprice}"></td>
							</tr>
							<tr>
								<td style="text-align: right; width: 100px;">收款方式：</td>
								<td>
									<select id="pay">
										<option value="0">微信</option>
										<option value="1">支付宝</option>
									</select>
								</td>
							</tr>
						</table>
					</div>
				</div>
				<div class="modal-footer">
					<button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button> 
					<button class="btn btn-primary" id="btn-primary" data-dismiss="modal" aria-hidden="true">付款</button>
				</div>
			</div>
			<div id="modal-container-959342" class="modal hide fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="width:800px; margin-left:-30%;">
				<div class="modal-header" style="border-bottom:0px;">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
					<span id="myModalLabel">订单号：${order.o_code}【发货】</span>
				</div>
				<div class="modal-body" style="padding:0px;">
					<div class="row-fluid">
						<table class="table table-bordered" style="margin:0px;">
							<tr>
								<td style="text-align: right; width: 100px;">订单号：</td>
								<td>${order.o_code}<input type="hidden" id="o_code" value="${order.o_code}"></td>
								<td style="text-align: right; width: 100px;">配送方式：</td>
								<td>快递<input type="hidden" id="u_id" value="${user.u_id}"></td>
							</tr>
							<tr>
								<td style="text-align: right; width: 100px;">配送费用：</td>
								<td>${afare}<input type="hidden" id="freight" value="${afare}"></td>
								<td style="text-align: right; width: 100px;">保价费用：</td>
								<td>￥0.00</td>
							</tr>
							<tr>
								<td style="text-align: right; width: 100px;">收货人姓名：</td>
								<td><input type="text" id="r_name"></td>
								<td style="text-align: right; width: 100px;">电话：</td>
								<td><input type="text" id="phone"></td>
							</tr>
							<tr>
								<td style="text-align: right; width: 100px;">手机：</td>
								<td><input type="text" id="tel"></td>
								<td style="text-align: right; width: 100px;">邮政编码：</td>
								<td><input type="text" id="zip_code"></td>
							</tr>
							<tr>
								<td style="text-align: right; width: 100px;">物流公司：</td>
								<td>
									<select id="e_name" style="width:100px;">
										<c:forEach items="${exlist}" var="u" varStatus="vs">
											<option value="${u.e_id}">${u.e_name}</option>
										</c:forEach>
									</select>
							</td>
								<td style="text-align: right; width: 100px;">配送单号：</td>
								<td><input type="text" id="courier_num"></td>
							</tr>
							<tr>
								<td style="text-align: right; width: 100px;">地区：</td>
								<td colspan="3">
									<input id="citySelect" name="a_name" type="text" class="city_input" style="width:605px;">
								</td>
							</tr>
							<tr>
								<td style="text-align: right; width: 100px;">地址：</td>
								<td colspan="3"><input type="text" id="address" style="width:605px;"></td>
							</tr>
						</table>
					</div>
				</div>
				<div class="modal-footer">
					<button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button> 
					<button class="btn btn-primary" id="bprimary" data-dismiss="modal" aria-hidden="true">发货</button>
				</div>
			</div>
			<div id="modal-container-959343" class="modal hide fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
				<div class="modal-header" style="border-bottom:0px;">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
					<span id="myModalLabel">订单号：${order.o_code}【退款到余额账户】</span>
				</div>
				<div class="modal-body" style="padding:0px;">
					<div class="row-fluid">
						<table class="table table-bordered" style="margin:0px;">
							<tr>
								<td style="text-align: right; width: 100px;">订单号：</td>
								<td>${order.o_code}<input type="hidden" id="o_code" value="${order.o_code}"></td>
							</tr>
							<tr>
								<td style="text-align: right; width: 100px;">下单时间：</td>
								<td>${order.buy_date}<input type="hidden" id="u_name" value="${user.u_name}"></td>
							</tr>
							<tr>
								<td style="text-align: right; width: 100px;">订单金额：</td>
								<td>${aprice}</td>
							</tr>
							<tr>
								<td style="text-align: right; width: 100px;">退款金额：</td>
								<td><input type="text" id="gather_m" value="${aprice}"></td>
							</tr>
							<tr>
								<td style="text-align: right; width: 100px;">退款方式：</td>
								<td>
									<select id="pay">
										<option value="0">微信</option>
										<option value="1">支付宝</option>
									</select>
								</td>
							</tr>
							<tr>
								<td>商品编号</td>
								<td>
									<c:forEach items="${glist}" var="u" varStatus="vs">
										<input type="checkbox" name="checkbox" id="${u.g_code}">
										<span>${u.g_name}</span>
										<br>
									</c:forEach>
								</td>
							</tr>
						</table>
					</div>
				</div>
				<div class="modal-footer">
					<button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button> 
					<button class="btn btn-primary" id="primary" data-dismiss="modal" aria-hidden="true">退款</button>
				</div>
			</div>
		</div>
		<div class="span12" style="margin-top: 10px; width:100%;">
			<div class="row">
				<div class="span12" style="width:95%;">
					<div class="tabbable" id="tabs-141029">
						<ul class="nav nav-tabs">
							<li class="active">
								<a href="#panel-261201" data-toggle="tab">基本信息</a>
							</li>
							<li>
								<a href="#panel-757130" data-toggle="tab" id="selectrr">收退款记录</a>
							</li>
							<li>
								<a href="#panel-525344" data-toggle="tab">发货记录</a>
							</li>
						</ul>
						<div class="tab-content">
							<div class="tab-pane active" id="panel-261201">
								<div class="row-fluid">
									<div class="span12">
										<table class="table table-bordered">
											<thead>
												<tr>
													<th>商品名称</th>
													<th>商品原价</th>
													<th>实际价格</th>
													<th>商品数量</th>
													<th>小计</th>
													<th>发货状态</th>
												</tr>
											</thead>
											<tbody>
												<c:forEach items="${glist}" var="u" varStatus="vs">
													<tr>
														<td>${u.g_name}</td>
														<td>${u.g_price}</td>
														<td>${u.g_price}</td>
														<td>${u.g_num}</td>
														<td>${u.g_num*u.g_price}</td>
														<td>${u.deliver_state eq 0?"未发货":"已发货"}</td>
													</tr>
												</c:forEach>
											</tbody>
										</table>
									</div>
								</div>
								<div class="row-fluid">
									<div class="span6">
										<table class="table table-bordered">
											<tr style="background-color: #B3B3B3;">
												<td colspan="2" style="color: white;">订单金额明细</td>
											</tr>
											<tr>
												<td style="text-align: right; width: 100px;">商品总金额：</td>
												<td>${aprice}</td>
											</tr>
											<tr class="success">
												<td style="text-align: right; width: 100px;">配送费用：</td>
												<td>${afare}</td>
											</tr>
											<tr class="error">
												<td style="text-align: right; width: 100px;">保价费用：</td>
												<td>￥0.00</td>
											</tr>
											<tr class="warning">
												<td style="text-align: right; width: 100px;">税金：</td>
												<td>￥0.00</td>
											</tr>
											<tr class="info">
												<td style="text-align: right; width: 100px;">优惠总额：</td>
												<td>￥20.00</td>
											</tr>
											<tr>
												<td style="text-align: right; width: 100px;">加价或减价：</td>
												<td>￥0.00</td>
											</tr>
											<tr class="success">
												<td style="text-align: right; width: 100px;">订单总额：</td>
												<td>${od.o_price}</td>
											</tr>
											<tr class="error">
												<td style="text-align: right; width: 100px;">已支付金额：</td>
												<td></td>
											</tr>
										</table>
									</div>
									<div class="span6">
										<table class="table table-bordered">
											<tr style="background-color: #B3B3B3;">
												<td colspan="2" style="color: white;">收货人信息</td>
											</tr>
											<tr>
												<td style="text-align: right; width: 100px;">发货日期：</td>
												<td></td>
											</tr>
											<tr class="success">
												<td style="text-align: right; width: 100px;">姓名：</td>
												<td>${red.r_name}</td>
											</tr>
											<tr class="error">
												<td style="text-align: right; width: 100px;">电话：</td>
												<td>${red.phone}</td>
											</tr>
											<tr class="warning">
												<td style="text-align: right; width: 100px;">手机：</td>
												<td>${red.tel}</td>
											</tr>
											<tr class="info">
												<td style="text-align: right; width: 100px;">地区：</td>
												<td>${red.a_name}</td>
											</tr>
											<tr>
												<td style="text-align: right; width: 100px;">地址：</td>
												<td>${red.address}</td>
											</tr>
											<tr class="success">
												<td style="text-align: right; width: 100px;">邮编：</td>
												<td>${red.zip_code}</td>
											</tr>
											<tr class="error">
												<td style="text-align: right; width: 100px;">送货时间：</td>
												<td>${order.o_date}</td>
											</tr>
										</table>
									</div>
								</div>
								<div class="row-fluid">
									<div class="span6">
										<table class="table table-bordered">
											<tr style="background-color: #B3B3B3;">
												<td colspan="2" style="color: white;">配送支付信息</td>
											</tr>
											<tr>
												<td style="text-align: right; width: 100px;">配送方式：</td>
												<td>${order.ship_mode eq 0?"先收款后发货":"货到付款"}</td>
											</tr>
											<tr class="success">
												<td style="text-align: right; width: 100px;">商品重量：</td>
												<td></td>
											</tr>
											<tr class="error">
												<td style="text-align: right; width: 100px;">支付方式：</td>
												<td>${order.pay eq 0?"支付宝":"微信"}</td>
											</tr>
											<tr class="warning">
												<td style="text-align: right; width: 100px;">可得积分：</td>
												<td>${od.o_price}</td>
											</tr>
										</table>
									</div>
									<div class="span6">
										<table class="table table-bordered">
											<tr style="background-color: #B3B3B3;">
												<td colspan="2" style="color: white;">买家信息</td>
											</tr>
											<tr>
												<td style="text-align: right; width: 100px;">用户名：</td>
												<td>${user.u_name}</td>
											</tr>
											<tr class="success">
												<td style="text-align: right; width: 100px;">姓名：</td>
												<td>${vip.vname}</td>
											</tr>
											<tr class="info">
												<td style="text-align: right; width: 100px;">电话：</td>
												<td>${vip.phone}</td>
											</tr>
											<tr class="error">
												<td style="text-align: right; width: 100px;">地区：</td>
												<td>${vip.tel}</td>
											</tr>
											<tr class="warning">
												<td style="text-align: right; width: 100px;">Email：</td>
												<td>${vip.email}</td>
											</tr>
										</table>
									</div>
								</div>
								<div class="row-fluid">
									<div class="span6">
										<table class="table table-bordered">
											<tr style="background-color: #B3B3B3;">
												<td colspan="2" style="color: white;">订单信息</td>
											</tr>
											<tr>
												<td style="text-align: right; width: 100px;">订单号：</td>
												<td>${order.o_code}</td>
											</tr>
											<tr class="success">
												<td style="text-align: right; width: 100px;">当前状态：</td>
												<td>${order.o_states}</td>
											</tr>
											<tr class="error">
												<td style="text-align: right; width: 100px;">支付状态：</td>
												<td>${order.pay_state eq 0?"未支付":"已支付"}</td>
											</tr>
											<tr class="warning">
												<td style="text-align: right; width: 100px;">配送状态：</td>
												<td></td>
											</tr>
											<tr class="info">
												<td style="text-align: right; width: 100px;">订单类型：</td>
												<td></td>
											</tr>
											<tr>
												<td style="text-align: right; width: 100px;">订单所属：</td>
												<td></td>
											</tr>
										</table>
									</div>
								</div>
							</div>
							<div class="tab-pane" id="panel-757130">
								<div class="row-fluid">
									<div class="span6">
										<table class="table table-bordered">
											<tr style="background-color: #B3B3B3;">
												<td colspan="2" style="color: white;">收款单据</td>
											</tr>
											<tbody id="receipt"></tbody>
										</table>
									</div>
									<div class="span6">
										<table class="table table-bordered">
											<tr style="background-color: #B3B3B3;">
												<td colspan="2" style="color: white;">退款单据</td>
											</tr>
											<tbody id="return"></tbody>
										</table>
									</div>
								</div>
							</div>
							<div class="tab-pane" id="panel-525344">
								<div class="row-fluid">
									<div class="span12">
										<table class="table table-bordered">
											<thead>
												<tr>
													<th>配送时间</th>
													<th>配送方式</th>
													<th>物流公司</th>
													<th>物流单号</th>
													<th>收件人</th>
												</tr>
											</thead>
											<tbody>
												<tr>
													<td></td>
													<td></td>
													<td></td>
													<td></td>
													<td></td>
												</tr>
											</tbody>
										</table>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
</html>